<!--<meta name="csrf-token" content="{{ csrf_token() }}">-->
<script type="text/javascript" src="{{ asset('/bootstrap/js/bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/jquery-1.9.1.min.js') }}"></script>
<script>
    
	<!-- 2.设置全局ajax选项 -->
    $.ajaxSetup({
        headers:{
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

</script>
<style>


    #i {
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, .8);
        z-index: 998;
        position: fixed;
        top: 0;
        left: 0;
        opacity: 0.8;
    }
</style>

<!--遮罩层-->
<i id="i" style="display:none;"></i>



<!--登陆信息-->
<div class="container" id="container" style="width: 530px;border: 1px solid #9d9d9d;border-radius: 10px;margin-top:10%;position:fixed;left:50%;margin-left:-265px;background: #fff;z-index: 999;display: none;text-align: left;">
    <!-- 选项卡登陆注册标题 -->
    <ul class="nav nav-tabs" style="border: none">
        <li class="col-xs-6 text-center active" style="border: none">
            <a href="#tab1" data-toggle="tab" class="on"
               style="font-size: 18px;border: none;background: #fff;color: #555;cursor:pointer;">登 陆</a>
        </li>
        <li class="col-xs-6 text-center" style="border: none;">
            <a href="#tab2" data-toggle="tab" class="on"
               style="font-size: 18px;border: none;background: #fff;color: #555;cursor:pointer;">注 册</a>
        </li>
		<div id="x" style="position:absolute;right:15px;top:5px;z-index:99999;color:#333;font-size:14px;cursor: pointer">X<div>
    </ul>


    <!-- 登陆注册页面内容 -->
    <div class="tab-content">
	
        <!-- 登陆页面 -->
        <div class="tab-pane active" id="tab1" style="margin-top: 20px;">
            <div class="col-xs-offset-2 col-xs-8">
                <!--登陆底边框-->
                <i style="width: 240px;height: 2px;background: #d9534f;position: absolute;left: -74px;top: -20px"><span
                        style="position: absolute;left: 103px;top: 0;width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-top: 10px solid #d9534f;"><span
                        style="position: absolute;left: -10px;top: -13px;width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-top: 10px solid #fff;"></span></span></i>

                <form method="post" id="dologinForm" action="{{ url('/doLogin') }}">


					
                    <!--用户名-->
                    <div class="form-group">
                        <label>用户名</label>
                        <input type="text" name="name" placeholder="账号/手机号"
                               class="form-control ember-text-field ember-view" style="font-size: 12px"
                               required oninvalid="setCustomValidity('请输入账号/手机号！');"
                               oninput="setCustomValidity('');" value="{{ session('name') }}" />
						<input type="hidden" name="_token" value="{{ csrf_token() }}" />
                    </div>
                    <!--密码-->
                    <div class="form-group">
                        <label>密码</label>
                        <div class="password-input-wrapper ember-view">
                            <input type="password" name="pass" placeholder="密码"
                                   class="form-control ember-text-field ember-view"
                                   style="font-size: 12px" required
                                   oninvalid="setCustomValidity('请输入密码！');"
                                   oninput="setCustomValidity('');">
                        </div>
                    </div>
					<!--验证码-->
					<div class="form-group form_code">
						
						<label>验证码</label>
						
						<div class="password-input-wrapper ember-view" style="position: relative">

							<input type="text" name="loginCode" placeholder="请输入验证码"
								   class="form-control ember-text-field ember-view"  style="font-size: 12px;width:210px;" />

							<div style="position: absolute;right: 2px;top: 0px;width:78px;height:35px;border:1px solid #ddd;cursor:pointer;" >
								<img id="codeImg" src="{{ url('/code') }}" style="width:100%;height:100%">
							</div>
							<script>
								var codeImg = document.getElementById('codeImg');
								codeImg.onclick = function()
								{
									var str = "{{ url('/code') }}";
									var rand = Math.random();
									str += '/'+rand;
									this.src = str;
								}
							</script>
						</div>

					</div>
                    <!--提示信息-->
                    <div class="form-group text-danger">
                        @if( !empty(session('info')) )
                        {{ session('info') }}
                        @else
                        @endif
                    </div>
                    <!--登陆按钮-->
                    <div class="form-group">
                        <div class="ember-view">
                            <input type="submit" id="clickLogin"
                                   class="btn btn-loading   btn btn-danger btn-lg btn-block btn-loading-text btn-md"
                                   style="font-weight: 500;font-size: 14px;" value="点击登陆" />
                        </div>
                    </div>
                    <!--忘记密码-->
                    <div class="form-group">
                        <div>
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name='rememberMe'
                                           style="margin-left:-12px; margin-top: 2px"><?php if( isset($pass) ) { echo 'checked';} ?>
                                    &nbsp;一周免登录
                                    <a href="{{ url('/forget') }}" target="_blank"
                                       style="font-size:12px;width:100px;margin-left:200px;margin-top:-20px;display:block;  text-decoration: none">
                                        忘记密码？
                                    </a>
                                </label>
                            </div>
                        </div>
                    </div>

                    <!-- 三方登陆 -->
                    <div class="form-group third_login">
                        <p style="float: left"><span>使用第三方账号登陆 </span></p>

                        <div style="overflow:hidden;">
                            <a class="qq" href="#"></a>
                            <a class="wchat" href="{{ url('/weibo') }}"></a>
                            <a class="sinaw" href="#"></a>
						</div>
					</div>
				</form>
			</div>
		</div>
       

	   <!-- 注册页面-->
        <div class="tab-pane" id="tab2" style="margin-top: 20px">
            <div class="col-xs-offset-2 col-xs-8">
                <!--注册底边框-->
                <i style="width: 240px;height: 2px;background: #d9534f;position: absolute;left: 164px;top: -20px"><span
                        style="position: absolute;left: 113px;top: 0;width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-top: 10px solid #d9534f;"><span
                        style="position: absolute;left: -10px;top: -13px;width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-top: 10px solid #fff;"></span></span>
                </i>


                <!--账户-->
                <div class="form-group">
                    <label>账户</label>
                    <div class="password-input-wrapper ember-view">
                        <input type="text" name="regname" id="regname" placeholder="请输入账户"
                               class="form-control ember-text-field ember-view" required
                               oninvalid="setCustomValidity('请输入账户');"
                               oninput="setCustomValidity('');" style="font-size: 12px" value="{{ old('name') }}"/>
                    </div>
                </div>

                <!--手机号-->
                <div class="form-group">
                    <label>手机号</label>
                    <div class="password-input-wrapper ember-view">
                        <input type="text" name="regphone" id="regphone" placeholder="手机号" class="form-control ember-text-field ember-view" style="font-size:12px;" value="{{ old('phone') }}" />
                    </div>
                </div>


                <!--验证码-->
                <div class="form-group form_code">
                    
					<label>验证码</label>
                    
					<div class="password-input-wrapper ember-view" style="position: relative">

                        <input type="text" name="phoneCode" id="phoneCode" placeholder="请输入验证码"
                               class="form-control ember-text-field ember-view"  style="font-size: 12px;width:210px;" />

                        <div id="getPhoneCode" class="btn btn-group-md btn-default"
                             style="position: absolute;right: 0;top: 2px;font-size: 12px;width:80px;" >获取验证码
                        </div>
                    </div>

                </div>
				
				
                <!--密码-->
                <div class="form-group">
                    <label>密码</label>
                    <div class="password-input-wrapper ember-view">
                        <input type="password" name="regpass" id="regpass" placeholder="请输入密码"
                               class="form-control ember-text-field ember-view" required
                               oninvalid="setCustomValidity('请输入密码！');"
                               oninput="setCustomValidity('');" style="font-size: 12px" />
                    </div>
                </div>
                <!--确认密码-->
                <div class="form-group">
                    <label>确认密码</label>
                    <div class="password-input-wrapper ember-view">
                        <input type="password" name="repass" id="repass" placeholder="再次输入密码"
                               class="form-control ember-text-field ember-view" required
                               oninvalid="setCustomValidity('请再次输入密码！');"
                               oninput="setCustomValidity('');" style="font-size: 12px">
                    </div>
                </div>
                <!--提示信息-->
                <div class="form-group text-danger" id='regWarn'>
                </div>
                <!-- 注册按钮 -->
                <div class="form-group">
                    <div class="ember-view">
                        <button id="regForm"
                                class="btn btn-loading   btn btn-danger btn-lg btn-block btn-loading-text btn-md"
                                style="font-weight: 500;font-size: 14px">
                            点击注册
                        </button>
                    </div>
                </div>
                <div class="form-group">
                </div>
            </div>
        </div>
    </div>





</div>

<div id="info" info="{{ session('info') or '' }}"></div>
<div id="code" code=""></div>

        <script type="text/javascript">

            // 显示 登陆注册 面板
            function showBg() {

                var bh = $("body").height();
                var bw = $("body").width();
                $("#i").css({
                    height: bh,
                    width: bw,
                    display: "block"
                });
                $("#container").show();
            }


            $(function () {
                var info = $("#info").attr('info');
                // 有内容
                if (info) 
				{
                    // 面板自动显示
                    showBg();
                    //关闭灰色 jQuery 遮罩
                    $("#container").click(function (e) {
                        e ? e.stopPropagation() : event.cancelBubble = true;

                    });
                    $(document).click(function () {
                        $("#container").hide();
                        $("#i").hide();
                        location.reload();
                    })
                } else 
				{
                    $("#container").hide();
                    $("#i").hide();
                    // 需要 点击 才能显示
                    $("#comment_login,.replylogin").click(function () {
                        $("#i").show();
                        $("#container").show();
                        return false;
                    });
					
					
					// 登陆
					$('#loginLogin,#articlelogin,#collectLogin,#clubLogin,#focus').click(function () {
                        $("#i").show();
						$("#container").show();
						// 全部隐藏
						$(".tab-pane").hide();
						// 登录出来
						$("#tab1").show();
                        return false;
                    });
					
					// 注册
					$('#regLogin').click(function () {
                        $("#i").show();
						$("#container").show();
						// 全部隐藏
						$(".tab-pane").hide();
						// 注册出来
						$("#tab2").show();
                        return false;
                    });
					
					
					
					
                    $("#container").click(function (e) {
                        e ? e.stopPropagation() : event.cancelBubble = true;
                    });
                    $("#x").click(function () {
                        $("#container").hide();
                        $("#i").hide();
                    })

                }
            })


        </script>


        <!--点击登陆注册切换-->
        <script type="text/javascript">
		
		var mytime = null;		// 用于 何时 开始倒计时
		var total = 60;			// 验证码倒计时
		
		// 倒计时
		function clock(){
			
			if(total==0){
				// 可以重新获取验证码了
				$("#getPhoneCode").attr('disabled',false);
				$("#getPhoneCode").html('获取验证码');
				mytime=null;
				total=60;
				return false;
			}
			$("#getPhoneCode").html( total+"秒" );
			total--; 
			mytime=setTimeout("clock()",1000);
			
		}
		
			
		var _token = $('meta[name="csrf-token"]').attr('content');
            $(function () {

                
                // 发送 手机验证码
                $("#getPhoneCode").click(function () {
							
                    // 获取电话
                    var phone = $("#regphone").val();
                    $.ajax({
                        type: "post",
                        url: "{{ url('/getPhoneCode') }}",
                        data: {phone: phone, _token: _token},
                        async: true,
                        dataType: "json",
                        success: function (back) {
                            $('#regWarn').html('');
                            // 显示错误信息
                            $('#regWarn').html(back['show_info']);
                            $("#regWarn").slideDown(1500);
                            $("#regWarn").delay(1500).slideUp(1000);
                            // 设置 发送成功后的 验证码
                            $("#code").attr('code', back['url']);
							if(  back['show_info']=='发送成功，请注意查收' )
							{
								$("#getPhoneCode").attr('disabled',true);
								if( mytime==null )
								{ 
									// 开始倒计时
									clock(); 
								}
							}
                        }
                    });
                });

                // 点击 注册
                $("#regForm").click(function () {
                    var name = $("#regname").val();
                    var regphone = $("#regphone").val();
                    var pass = $("#regpass").val();
                    var repass = $("#repass").val();
                    var phoneCode = $("#phoneCode").val();
                    var code = $("#code").attr('code');
                    // 注册
                    var url = "{{ url('/doReg') }}";
                    $.ajax({
                        type: "post",
                        url: url,
                        data: {
                            name: name,
                            phone: regphone,
                            phoneCode: phoneCode,
                            code: code,
                            pass: pass,
                            repass: repass,
                            _token: _token
                        },
                        async: false,
                        dataType: "json",
                        success: function (back) {
                            $('#regWarn').html('');
                            // 显示错误信息
                            $('#regWarn').html(back['show_info']);
                            $("#regWarn").slideDown(1500);
                            $("#regWarn").delay(1500).slideUp(1000);
                            if (back['show_info'] == '注册成功,可立即登录') {
                                // $("#regForm").attr('disabled',true);
                                $('input').val('');
                                $('#clickLogin').val('点击登录');
								setTimeout(function(){
									// 全部隐藏
									$(".tab-pane").hide();
									// 登录出来
									$("#tab1").show();
								},1500);
                            }
                        }
                    });
                });


            });


            $(document).ready(function () {
                $(".tab-pane").hide();
                $(".tab-pane:first").addClass("active").show();
                $(".nav-tabs li").click(function () {
                    $("ul.nav-tabs li a").removeClass("active");
                    $(this).addClass("active");
                    $(".tab-pane").hide();
                    var activeTab = $(this).find("a").attr("href");
                    $(activeTab).show();
                    return false;
                });
            });
        </script>